package com.mightybird.designpattern.structural.flyweight;

import com.mightybird.designpattern.structural.flyweight.concrete.Man;
import com.mightybird.designpattern.structural.flyweight.concrete.Woman;

import java.util.HashMap;
import java.util.Map;

public class FlyweightFactory {
    private static FlyweightFactory instance = new FlyweightFactory();
    private static Map<String, Flyweight> flyweights;

    private FlyweightFactory() {
        flyweights = new HashMap<>();
        flyweights.put("m", new Man());
        flyweights.put("w", new Woman());
    }

    public static FlyweightFactory getInstance() {
        return instance;
    }

    public Flyweight getFlyweight(String type) {
        return flyweights.get(type);
    }
}
